<template>
  <div class="homeapp">
    <!-- 头部1 -->
    <mt-header fixed title="黑马程序员">
      <mt-button icon="back" slot="left" @click="backrouter" v-show="flag"
        >back</mt-button
      >
    </mt-header>
    <!-- 中间 -->
    <router-view></router-view>
    <!-- 尾部 -->
    <nav class="mui-bar mui-bar-tab">
      <router-link class="mui-tab-item1" to="/login">
        <span class="mui-icon mui-icon-home"></span>
        <span class="mui-tab-label">首页</span>
      </router-link>
      <router-link class="mui-tab-item1" to="/member">
        <span class="mui-icon mui-icon-email"
          ><span class="mui-badge">9</span></span
        >
        <span class="mui-tab-label">消息</span>
      </router-link>
      <router-link class="mui-tab-item1" to="/shopcar">
        <span class="mui-icon mui-icon-contact" id="buys"></span>
        <span class="mui-tab-label">购物车</span>
      </router-link>
      <router-link class="mui-tab-item1" to="/serach">
        <span class="mui-icon mui-icon-gear"></span>
        <span class="mui-tab-label">设置</span>
      </router-link>
    </nav>
  </div>
</template>

<script>
export default {
  data() {
    return {
      selected: {},
      flag: false
    }
  },
  methods: {
    getlist() {
      console.log('1')
    },
    backrouter() {
      this.$router.go(-1)
    }
  },
  watch: {
    '$route.path': function(res) {
      if (res === '/login') {
        this.flag = false
      } else {
        this.flag = true
      }
    }
  }
}
</script>

<style lang="less" scoped>
.homeapp {
  padding-top: 40px;
  padding-bottom: 51px;
}
</style>
